/**
 * 
 */
package com.maohi.software.arii.annotations;

import java.lang.annotation.Annotation;

/**
 * @author heifara
 * 
 */
public final class ExtensionImpl implements Extension {

	public static Extension extension(String iId) {
		return new ExtensionImpl(iId);
	}

	private final String id;

	public ExtensionImpl(String aId) {
		this.id = aId;
	}

	@Override
	public Class<? extends Annotation> annotationType() {
		return Extension.class;
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof Extension)) {
			return false;
		}

		Extension other = (Extension) obj;
		return this.id.equals(other.value());
	}

	@Override
	public int hashCode() {
		// This is specified in java.lang.Annotation.
		return (127 * "value".hashCode()) ^ this.id.hashCode();
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("ExtensionImpl [id=");
		builder.append(this.id);
		builder.append("]");
		return builder.toString();
	}

	@Override
	public String value() {
		return this.id;
	}

}
